package middlewares

import (
	"github.com/kataras/iris"
	"manageCrontab/lib"
	"manageCrontab/models"
)

func VerifyUserLogin(ctx iris.Context) {
	shareInformation := "this is a sharable information between handlers"
	requestPath := ctx.Path()
	println("Before the mainHandler: " + requestPath)
	ctx.Values().Set("info", shareInformation)
	if ok, _ := lib.SessionObj(ctx).GetBoolean("authenticated"); ok {
		resp := lib.GetJsonResponse(models.LOGIN_FIAL, nil, "请先登录")
		ctx.JSON(resp)
	} else {
		ctx.Next() // 执行下一个处理器。
	}

}
